package interview8;

import org.junit.Test;

/**
 * @author Jack
 * @date 2019-11-05-11:13
 */
public class SolutionTest {


    @Test
    public void testNormalTree(){
        Node a = new Node("a");
        Node b = new Node("b");
        Node c = new Node("c");
        Node d = new Node("d");
        Node e = new Node("e");
        Node f = new Node("f");
        Node g = new Node("g");
        Node h = new Node("h");
        Node i = new Node("i");
        a.leftChild = b;
        a.rightChild = c;
        b.leftChild = d;
        b.rightChild = e;
        e.leftChild = h;
        e.rightChild = i;
        c.leftChild = f;
        c.rightChild = g;
        b.father = a;
        c.father = a;
        d.father = b;
        e.father = b;
        h.father = e;
        i.father = e;
        f.father = c;
        g.father = c;
        Solution solution = new Solution();
        Node nextNode = solution.getNextNodeByInOrder(i);
        if (nextNode != null) {
            System.out.println("节点"+i.value+"的下一个中序遍历节点是:"+nextNode.value);
        } else {
            System.out.println("输入的是最后一个叶子节点或输入的节点为null");
        }
    }


}
